{include file="public/layout" /}
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-card layui-col-md12">
          <div class="layui-card-header">绘画申请记录</div>
          <div class="layui-card-body" pad15>
						<div class="layui-col-md4" style="padding-bottom:10px">
<!--							<button class="layui-btn layui-btn-primary layuiadmin-btn-list" onclick="datadel(0)">删除</button>-->
						</div>
						<div class="layui-form layui-col-md8 layui-form-search">
                            <div class="layui-inline layuiadmin-input-useradmin">
                                <label class="layui-form-label">会员ID</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="mid" autocomplete="off" class="layui-input" value="">
                                </div>
                            </div>
							<div class="layui-inline layuiadmin-input-useradmin">
								<label class="layui-form-label">创作风格</label>
								<div class="layui-input-inline">
									<input type="text" name="ai_style" autocomplete="off" class="layui-input" value="">
								</div>
							</div>
							<div class="layui-inline">
								<div class="layui-input-inline" style="margin-left:30px">
									<select name="status">
										<option value="all">全部</option>
										<option value="0">未支付</option>
										<option value="1">已支付</option>
									</select>
								</div>
							</div>
							<div class="layui-inline">
								<button class="layui-btn layuiadmin-btn-replys" lay-submit="" lay-filter="LAY-app-forumreply-search">
									<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
								</button>
							</div>
						</div>
						<div class="layui-col-md12">
							<table id="tabledata" lay-filter="tabledata"></table>
						</div>
          </div>
        </div>
    </div>
  </div>
	<script>
  var table = layui.table;
	var datawhere = {};
  //数据表
  var tableIns = table.render({
    elem: '#tabledata'
    ,url: "{$Request.url}" //数据接口
    ,page: true //开启分页
    ,cols: [[ //表头
			{type:"checkbox"},
      {field: 'id', title: 'ID',  width:80},
      {field: 'nickname', title: '申请会员'},
          {field: 'ai_text', title: '创作文本'},
          {field: 'ai_style', title: '创作风格'},
          {field: 'taskId', title: '百度任务ID'},
		  {field: 'status', title: '支付状态',templet: function (d) {
				  var html = '';
				  if(d.status==0) html+='<div style="color:#ff8758">未支付</span>';
				  if(d.status==1 ) html+='<div style="color:#008000">已支付</span>';
				  return html;
			  }},
      {field: 'pic', title: '图片',templet: function (d) {
          if(d.pic) {
              return '<div><img src="'+d.pic+'" style="height:50px"/></div>'
          }
					return '';
      }},
      {field: 'operation', title: '操作',templet: function(d){
				var html = '';
			  html += '<a class="layui-btn layui-btn-xs" onclick="view('+d.id+')">查看</a>';

				return html;
      },width:250}
    ]]
  });
	//排序
	table.on('sort(tabledata)', function(obj){
		datawhere.field = obj.field;
		datawhere.order = obj.type;
		tableIns.reload({
			initSort: obj,
			where: datawhere
		});
	});
	//检索
	layui.form.on('submit(LAY-app-forumreply-search)', function(obj){
		var field = obj.field
		var olddatawhere = datawhere
		datawhere = field
		datawhere.field = olddatawhere.field
		datawhere.order = olddatawhere.order
		tableIns.reload({
			where: datawhere,
			page: {curr: 1}
		});
	})
	//删除
	function datadel(id){
		var ids = [];
		if(id==0){
			var checkStatus = table.checkStatus('tabledata')
			var checkData = checkStatus.data; //得到选中的数据
			if(checkData.length === 0){
				 return layer.msg('请选择数据');
			}
			var ids = [];
			for(var i=0;i<checkData.length;i++){
				ids.push(checkData[i]['id']);
			}
		}else{
			ids.push(id)
		}
		layer.confirm('确定要删除吗?',{icon: 7, title:'操作确认'}, function(index){
			//do something
			layer.close(index);
			var index = layer.load();
			$.post("{:url('del')}",{ids:ids},function(data){
				layer.close(index);
				dialog(data.msg,data.status);
				tableIns.reload()
			})
		});
	}
  function view(id){
	  layer.open({
		  title: '添加',
		  type: 2,
		  shadeClose: true,
		  area: ['100%','100%'],
		  scrollbar:false,
		  content: '{:url("view")}/id'+id
	  });
  }
	</script>
	<div id="NewsToolBox"></div>
</body>
</html>